import { marked } from 'marked';
/**
 * 把文本转换成node节点
 * @param txt
 * @param download
 * @returns
 */
export const getTxtNode = (txt: string, download = false) => {
	if (download)
		return (
			<div>
				
				<a target="blank" href={'https://lizhan.fun/download/save/' + txt}>
					下载文档
				</a>
			</div>
		);
	// if (txt.startsWith('#') || txt.startsWith('```')) {
	try {
		let html = marked(txt) as string;
		if (html.startsWith('<pre>'))
			return (
				<div
					dangerouslySetInnerHTML={{
						__html: html,
					}}
				>
					{/* {html} */}
				</div>
			);
		// return (
		// 	<SyntaxHighlighter
		// 		language="javascript"
		// 		style={oneDark}
		// 		showLineNumbers
		// 	>
		// 		{html}
		// 	</SyntaxHighlighter>
		// );

		return (
			<div
				dangerouslySetInnerHTML={{
					__html: html,
				}}
			>
			{/* {thm} */}
			</div>
		);
	} catch (e) {
		console.log(e);
		<div
			dangerouslySetInnerHTML={{
				__html: txt,
			}}
		>
		
		</div>;
	}
	// }
	// return (
	// 	<div
	// 		dangerouslySetInnerHTML={{
	// 			__html: txt,
	// 		}}
	// 	></div>
	// );
};
